package top.kaoshanji.ch04;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import top.kaoshanji.ch04.employee.Employee;

/**
 * 代码清单 ch04-02：用户自定义类
 * @see top.kaoshanji.ch04.employee.Employee
 * author kaoshanji
 * ^_^
 * create time 2024/11/24 20:48
 */
public class EmployeeTest {

    private static final Logger logger = LogManager.getLogger(EmployeeTest.class);

    public static void main(String[] args) {
        logger.info("...代码清单 ch04-02：用户自定义类...");

        Employee[] staff = new Employee[3];

        staff[0] = new Employee("Carl Cracker", 75000, 1987, 12, 15);
        staff[1] = new Employee("Harry Hacker", 50000, 1989, 10, 1);
        staff[2] = new Employee("Tony Tester", 40000, 1990, 3, 15);


        // 加薪 5%
        for (Employee e: staff) {
            e.raiseSalary(5);
        }

        // 通过(公共)方法访问(私有)字段
        // 看看名字、薪水(上调5%)、入职日期
        for (Employee e: staff) {
            System.out.println("name=" + e.getName() + ",salary=" + e.getSalary() + ",hireDay=" + e.getHireDay());
        }


    }

}
